package com.example.myapplication;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.example.myapplication.base.BaseActivity;
import com.example.myapplication.utils.LogUtils;

public class CarViewActivity extends BaseActivity {

    private View view_img;
    private ImageView view_img1;
    private Button btn_cb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_car_view);

        btn_cb = findViewById(R.id.btn_cb);
        view_img = findViewById(R.id.view_img);
        view_img1 = findViewById(R.id.view_img1);

        btn_cb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(getViewBitmap(view_img)==null){
                    LogUtils.i("dove","得到绘制图为null");
                    return;
                }
                view_img1.setImageBitmap(getViewBitmap(view_img));
            }
        });
    }

    public static Bitmap getViewBitmap(View view) {
        Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    }

}
